package com.baizhi.springbootday0101.controller;

import com.baizhi.springbootday0101.entity.Book;
import com.baizhi.springbootday0101.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class BookController {
	@Autowired
	private BookService bookService;

//	查询所有的图书

	@RequestMapping("/selectAll")
	public Map selectAll(int page,int limit,String name){
		Map map = bookService.selectAll(page, limit, name);
		return map;
	}


	//添加
	@RequestMapping("/insertBook")
	public Map insertBook(Book book){
		Map map = bookService.insertBook(book);
		return map;
	}


	//修改
	@RequestMapping("/updateBook")
	public Map updateBook(Book book){
		return bookService.updateBook(book);
	}


	//删除
	@RequestMapping("/deleteBook")
	public Map deleteBook(int bookId){
		return bookService.deleteBook(bookId);
	}
}
